'use strict';

const Controller = require('egg').Controller;

const { successRes } = require('../../res/index');

/**
 * @Controller 抽奖
 */

class IndexController extends Controller {
    /**
     * @summary 全部奖品
     * @router get /prizeAll
     * @response 200 baseResponse
     */
    async allPrize() {
        const { ctx } = this;
        let data = await ctx.service.lucky.index.getAllPrize()
        ctx.body = successRes(data)
    };
    /**
     * @summary 查询中奖情况
     * @router get /prizeDesc
     * @response 200 baseResponse
     */
    async prizeDesc() {
        const { ctx } = this;
        let data = await ctx.service.lucky.index.getPrizeDesc();
        ctx.body = successRes(data)
    };
    /**
     * @summary 奖品数目
     * @router get /prizeNum
     * @response 200 baseResponse
     */
    async prizeNum() {
        const { ctx } = this;
        let data = await ctx.service.lucky.index.getPrizeNum();
        ctx.body = successRes(data)
    };
    /**
     * @summary 设置奖品九宫格
     * @router get /sudoku
     * @response 200 baseResponse
     */
    async sudoku() {
        const { ctx } = this;
        let data = await ctx.service.lucky.index.getSudoku();
        ctx.body = successRes(data)
    };
    /**
     * @summary 记录用户抽奖记录
     * @router post /getLucky
     * @response 200 baseResponse
     */
    async getLucky() {
        const { ctx } = this;
        const obj = ctx.request.body
        let data = await ctx.service.lucky.index.getLucky(obj);
        ctx.body = data
    };
    /**
     * @summary 查询用户是否可以抽奖
     * @router get /isLucky
     * @response 200 baseResponse
     */
    async isLucky() {
        const { ctx } = this;
        const userId = ctx.query.userId;
        let data = await ctx.service.lucky.index.getIsLucky(userId);
        ctx.body = successRes(data)
    };
    /**
     * @summary 随机获取奖品
     * @router get /luckyGood
     * @response 200 baseResponse
     */
    async luckyGood() {
        const { ctx } = this;
        let data = await ctx.service.lucky.index.getluckyGood();
        ctx.body = successRes(data)
    }
}

module.exports = IndexController;